//@author A0103459H

#include "stdafx.h"
#include "CppUnitTest.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTestCreateStdTimeStr
{		
	TEST_CLASS(UnitTest1)
	{
	public:
		
		TEST_METHOD(inHHMMhrs_DDslashMMslashYYYY)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "1623hrs 20/12/2014";
			std::string expected = "16 23 20 12 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(inHHMMhrs_DDslashMMslashYY)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "1623hrs 20/12/14";
			std::string expected = "16 23 20 12 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(DDslashMMslashYYYY_HHMMhrs)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "20/12/2014 1623hrs";
			std::string expected = "16 23 20 12 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(D_M_YY_HHMMhrs)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/02/14 1623hrs";
			std::string expected = "16 23 2 02 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}
	
		TEST_METHOD(D_M_YY_H_MMam)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/02/14 8:30am";
			std::string expected = "08 30 2 02 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		
		TEST_METHOD(D_M_YY_H_MMpm)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/02/14 8:30pm";
			std::string expected = "20 30 2 02 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		
		TEST_METHOD(D_M_YY_12_MMam)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/02/14 12:30am";
			std::string expected = "00 30 2 02 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(D_M_YY_12_MMpm)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/02/14 12:30pm";
			std::string expected = "12 30 2 02 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(D_M_YY_HHMM)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/02/14 1230";
			std::string expected = "12 30 2 02 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(D_M_YY_0830)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/2/14 0830";
			std::string expected = "08 30 2 2 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(D_M_HHMM)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/2 0830";
			std::string expected = "08 30 2 2 ";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(HHMM)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "0830";
			std::string expected = "08 30";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		TEST_METHOD(D_M_YY)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "2/2/14";
			std::string expected = "00 00 2 2 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}

		
		TEST_METHOD(garbage)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "blah";
			std::string expected = "";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
			//Assert::IsTrue(returnFlag);
		}

		TEST_METHOD(dayName)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			std::string input = "sat";
			std::string expected = "00 00 19 4 2014";

			Interpreter interObj;

			std::string output = interObj.createStdTimeStringForInput(input, &returnFlag);

			Assert::AreEqual(expected, output);
		}


		TEST_METHOD(Interpretdayname)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			string command, expectedCommand = "add";
			std::string input = "add taskname from mon 5pm to Tue";
			std::vector<string> expected;
			
			expected.push_back("taskname");
			expected.push_back("Mon Apr 14 17:00:00 2014");
			expected.push_back("Tue Apr 15 00:00:00 2014");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");

			vector<string> output;

			Interpreter interObj;

			output = interObj.interpret(input, &command, &returnFlag);

			for (int i = 0; i < 7; i++) {
				Assert::AreEqual(expected[i], output[i]);
			}
			Assert::AreEqual(expectedCommand, command);
		}



		TEST_METHOD(InterpretdayinCTimeForm)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			string command, expectedCommand = "add";
			std::string input = "add taskname from Mon Apr 14 00:00:00 2014 to Wed Apr 16 00:00:00 2014";
			std::vector<string> expected;
			
			expected.push_back("taskname");
			expected.push_back("Mon Apr 14 00:00:00 2014");
			expected.push_back("Wed Apr 16 00:00:00 2014");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");

			vector<string> output;

			Interpreter interObj;

			output = interObj.interpret(input, &command, &returnFlag);

			for (int i = 0; i < 7; i++) {
				Assert::AreEqual(expected[i], output[i]);
			}
			Assert::AreEqual(expectedCommand, command);
		}

		TEST_METHOD(InterpretdaynameDeadlineTask)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			string command, expectedCommand = "add";
			std::string input = "add taskname by wed 5pm";
			std::vector<string> expected;
			
			expected.push_back("taskname");
			expected.push_back("");
			expected.push_back("Wed Apr 16 17:00:00 2014");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");

			vector<string> output;

			Interpreter interObj;

			output = interObj.interpret(input, &command, &returnFlag);

			for (int i = 0; i < 7; i++) {
				Assert::AreEqual(expected[i], output[i]);
			}
			Assert::AreEqual(expectedCommand, command);
		}

		TEST_METHOD(Interpretdate)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			string command, expectedCommand = "add";
			std::string input = "add taskname from 15/5 5pm to 16/5";
			std::vector<string> expected;
			
			expected.push_back("taskname");
			expected.push_back("Thu May 15 17:00:00 2014");
			expected.push_back("Fri May 16 00:00:00 2014");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");

			vector<string> output;

			Interpreter interObj;

			output = interObj.interpret(input, &command, &returnFlag);

			for (int i = 0; i < 7; i++) {
				Assert::AreEqual(expected[i], output[i]);
			}
			Assert::AreEqual(expectedCommand, command);
		}

		TEST_METHOD(InterpretFullDateTIme)
		{
			// TODO: Your test code here
			int returnFlag = 0;
			string command, expectedCommand = "add";
			std::string input = "add taskname from 14/4/14 1300 to 15/4 6am";
			std::vector<string> expected;
			
			expected.push_back("taskname");
			expected.push_back("Mon Apr 14 13:00:00 2014");
			expected.push_back("Tue Apr 15 06:00:00 2014");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");
			expected.push_back("");

			vector<string> output;

			Interpreter interObj;

			output = interObj.interpret(input, &command, &returnFlag);

			for (int i = 0; i < 7; i++) {
				Assert::AreEqual(expected[i], output[i]);
			}
			Assert::AreEqual(expectedCommand, command);
		}

	};

}